<?php
class User_model extends CI_Model{
	
	
	function __construct(){
		parent::__construct();
	}
	
	function add(){
		$this->username = $this->input->post('username');
		$this->password = sha1($this->input->post('pwd'));
		$this->email = $this->input->post('email');
		$this->reg_time = time();
		
		$this->db->insert('ci_user',$this);
		$newuid = $this->db->insert_id();
		$this->db->insert('ci_user_plus',array('uid'=>$newuid,'groupid'=>2));
		return $newuid;
	}
	
	function get_user($num,$offset){
		$this->db->select('*');
		$this->db->from('ci_user');
		$this->db->join('ci_user_plus', 'ci_user_plus.uid = ci_user.uid','left');
		$this->db->join('ci_group', 'ci_user_plus.groupid = ci_group.groupid','left');
		$this->db->order_by("ci_user.uid", "asc");
		$this->db->limit($num);
		$this->db->offset($offset);
		$query = $this->db->get();
		return $query;
	}
}
?>